package projects.telerik.pageObjects.elements;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import projects.telerik.pageObjects.TelerikPageBase;
import fw.ApplicationManager;

public class IndexPageElements extends TelerikPageBase {
	private static final String FIRST_LETTER_IN_LIST = "//tr[@id='ctl00_ContentPlaceHolder2_RadGrid1_ctl00__0']";
	private static final String LETTER_LIST = "//tr[contains (@id,'ctl00_ContentPlaceHolder2_RadGrid1_ctl00')]";
	private static final String BLOCK_LOADER = "ctl00_ContentPlaceHolder1_RadAjaxLoadingPanel1ctl00_ContentPlaceHolder2_RadGrid1";
	private static final String LINKS_HOLDER = "//div[@id='ctl00_ContentPlaceHolder1_RadTreeView1']";
	private static final String LETTER_TABLE = "//table[@id='ctl00_ContentPlaceHolder2_RadGrid1_ctl00']";

	public IndexPageElements(ApplicationManager app) {
		super(app);
	}

	public WebElement linkFolder(String folderName) {
		String[] locators = { LINKS_HOLDER, "//span[.='" + folderName + "']" };
		return app.elementFinder().findDynamic(locators);
	}

	public WebElement linkInboxFolder(String folderName) {
		String[] locators = { LINKS_HOLDER, "//span[.='" + folderName + "']" };
		return app.elementFinder().findDynamic(locators);
	}

	public WebElement firstLetterInFolder() {
		String[] locators = { LETTER_TABLE, FIRST_LETTER_IN_LIST };

		return app.elementFinder().findDynamic(locators);
	}

	public List<WebElement> letterList() {
		String[] locators = { LETTER_TABLE, LETTER_LIST };

		return app.elementFinder().findDynamicList(locators);
	}

	public WebElement loader() {
		return app.elementFinder().findDynamic(By.id(BLOCK_LOADER));
	}
}
